1. Field of the Invention
The present invention relates to an image processing apparatus, a computer-readable recording medium for recording an image processing program, and an image processing method, and the image processing apparatus, the image processing program, and the image processing method are for generating a color image with sampling positions where R, G and B pixels coincide from an RGB Bayer array image.
2. Description of the Related Art
With the progress in digital instruments and the spread of personal computers, digital cameras have come into wide use as simple image inputting means.
FIG. 21 is a block diagram showing an exemplary configuration of a conventional digital camera. The digital camera has an image pickup unit. The image pickup unit includes: an optical system 2101 that forms an optical image of a subject; an image pickup device 2102 that photoelectrically converts the optical image formed by the optical system 2101 to generate an electric image signal; a pre-processing unit 2103 that performs analog pre-processing such as gradation conversion processing and white balance processing on the image signal outputted from the image pickup device 2102; and an A/D conversion unit 2104 that converts an analog signal outputted from the pre-processing unit 2103 into digital data.
The digital camera further includes: an interpolation processing unit 2105 that receives digital image data from the A/D conversion unit 2104 and performs interpolation processing; a size conversion unit 2106 that changes the size of the image subjected to the interpolation processing; a Y/C: conversion unit 2107 that converts the image data whose size has been changed into a luminance signal and color difference signals; and a compressing/recording unit 2108 that performs compression processing using the JPEG (Joint Photographic Coding Experts Group) method, for example, to record the image data which has been converted into the luminance signal and the color difference signals.
The JPEG method is a compression method generally used in digital cameras when compressing images. Note that, in the JPEG method, compression processing is generally performed after an RGB signal was converted into a luminance signal and color difference signals.
Furthermore, the digital camera includes a control unit, not shown, that performs control of the digital camera including photographing operation by the optical system 2101 and the pre-processing operation by the pre-processing unit 2103.
The above-described digital camera is shown as an exemplary configuration of what is called a consumer digital camera. The consumer digital camera generally uses a single-plate image pickup device. Specifically, for example, a primary color Bayer pattern single-plate image pickup device is used as the image pickup device 2102. The primary color Bayer pattern single-plate image pickup device includes red (R), blue (B) and green (G) filters arranged in a mosaic pattern as shown in FIG. 6 related to an embodiment of the present invention, and only data of one of the red, green and blue colors can be obtained at each pixel and the other two colors are missing.
Since data of all the three primary colors are needed for each pixel position to create a color image, the missing color components at each pixel are interpolated from surrounding pixels by the interpolation processing unit 2105 after image pickup.
When such interpolation processing is performed to interpolate the missing color components from surrounding pixels, there is a possibility that the color of the interpolated position differs from the original color. As a result, there is a problem that what is called a false color easily occurs.
Generation of a false signal tends to be more remarkable in the color difference signals Cr, Cb than in the luminance signal Y. The luminance signal Y and the color difference signals Cr, Cb are calculated as shown in the following equations based on an RGB signal.Y=0.29900×R+0.58700×G+0.11400×B Cb=−0.16874×R−0.33126×G+0.50000×B Cr=0.50000×R−0.41869×G−0.08131×B 
As is known from these equations, the ratio of G signals is high in the Y signal, the ratio of B signals is high in the Cb signal, and the ratio of R signals is high in the Cr signal. Incidentally, in primary color Bayer pattern image pickup devices, the ratio of the number of pixels of the three colors is expressed as follows, red (R):green (G):blue (B)=1:2:1. When data obtained by a Bayer array image pickup device is interpolated to generate an RGB signal, error due to the interpolation tends to become larger in the R signals and the B signals which have small number of pixels than in the G signals. Accordingly, the error becomes larger in the color difference signal Cb in which the ratio of B signals is high and the color difference signal Cr in which the ratio of R signals is high than in the luminance signal Y.
When, in particular, a still image is picked up by a digital camera, false color has a significant influence on an image quality, so that there is a need to suppress generation of the false color. Such technology is disclosed, for example, in Japanese Patent Application Laid-Open Publication No. 11-243554 as an interpolation method for suppressing generation of false color and in Japanese Patent Application Laid-Open Publication No. 2000-217123 as a false color reducing method using a Median filter. However, the technologies disclosed in the Japanese Patent Application Laid-Open Publication Nos. 11-243554 and 2000-217123 have such a problem that the circuit scale is increased when building hardware.
As a technology for generating pixels each containing three primary colors while preventing an increase in circuit scale. Japanese Patent Application Laid-Open Publication No, 2003-235052, for example, discloses a technology for creating one colored pixel from four pixels (2×2 pixels) arranged in Bayer array, as shown in FIG. 22. FIG. 22 is a view showing a part of an image photographed by a primary color Bayer pattern image pickup device. In the technology, pixel values of pixels Rs, Gs and Bs having different image-forming positions (spatial positions) on the image pickup device are processed as pixel values obtained at a pixel position of a point PA. Since the pixel Gs has two pixel values, an average value of the two pixel values is used as the pixel value of G at the pixel position of the point PA. Such a technology eliminates the need for reproducing an entire image and prevents an increase in the circuit scale.